简体   繁体   English

按钮不会在Safari 10中包装和溢出容器(在Edge和Chrome中很好用)

[英]Buttons not wrapping and overflowing container in Safari 10 (fine in Edge and Chrome)

Supposed to look like the below (does in Edge & Chrome): 应该看起来像下面的样子(在Edge&Chrome中确实如此):

在此处输入图片说明

But looks like this in Safari 10: 但是在Safari 10中看起来像这样:

在此处输入图片说明

I've read a few SO questions that have not help resolve the issue. 我读了一些SO问题,这些问题无助于解决问题。 Most recently this one: 最近的一个:

Flexbox not working on button or fieldset elements Flexbox无法在按钮或字段集元素上使用

The answers are not resolving my issue. 答案无法解决我的问题。

How do I get a new button to wrap to a new line instead of overflowing the container? 我如何获得一个新的按钮来换行而不是使容器溢出?

Here is the Sass and ReactJS component I have. 这是我拥有的Sass和ReactJS组件。 Also, I am using Bootstrap 4. 另外,我正在使用Bootstrap 4。

class BasicQueryCuts extends Component {
    constructor(props) {
        super(props);
        this.state = {
            cuts: {}
        }

        this.clearSelection = this.clearSelection.bind(this);
        this.selectAll = this.selectAll.bind(this);
    }

    clearSelection() {
        this.setState({
            cuts: {}
        })
        this.props.clearCuts();

    }

    // pieces together the cuts that are selected
    onCutSelect(cut, str) {

        // want to make sure it stays a number
        // so that it matches the server data
        // tends to convert to string if not specific
        cut = Number(cut);

        this.setState(
            ({cuts: prevCuts}) => (
                this.state.cuts[cut] && str !== 'all'
                ?
                    {cuts: {...prevCuts, [cut]: undefined }}                  
                :
                    {cuts: {...prevCuts, [cut]: cut }}
            ),
            () => this.props.basicQueryResults(this.state.cuts)
        )
    }

    selectAll() {
        const { country } = this.props;
        let { query_data } = this.props;

        if (query_data) {
            if (query_data[0].Country && country) {
                var data = _.filter(query_data, {'Country': country});
            } else {
                var data = query_data;
            } 
        }

        _.map(
            data, c => {
                this.onCutSelect(c.SortOrder, 'all');
            }
        )        
    }

    // These buttons will allow selecting everything, or clearing the selection
    renderAllNothingButtons() {
        let { query_data } = this.props;

        // generate the list of cuts
        if (query_data) {
            return (
                <Row>
                    <Col>
                        <Button color='primary' key='all' className='cuts-btn' onClick={this.selectAll}>
                            Select All
                        </Button>
                    </Col>
                    <Col>
                        <Button color='danger' key='cancel' className='cuts-btn' onClick={this.clearSelection}>
                            Clear All
                        </Button>
                    </Col>
                </Row>
            )            
        }
    }

    // renders the cut multi-list, by first ordering what comes from
    // the server and then depending on the survey
    // setting up the option and value keys
    renderCutsButtons() {
        const { country } = this.props;
        let { query_data } = this.props;

        if (query_data) {
            if (query_data[0].Country && country) {
                var data = _.filter(query_data, {'Country': country});
            } else {
                var data = query_data;
            } 
        }

        // generate the list of cuts
        return (
            <Row>
                {_.map(data, c => {
                    var cut = c.RptCutCat + ': ' + c.RptCut
                    return (
                        <Col key={c.SortOrder}>
                            <Button 
                                className={this.state.cuts[c.SortOrder] ? 'cuts-btn-active' : 'cuts-btn'}
                                key={c.SortOrder}
                                value={c.SortOrder}
                                onClick={event => this.onCutSelect(event.target.value, 'single')}
                            >
                                <span>{cut}</span>
                            </Button>
                        </Col>
                    )}
                )}
            </Row>
        )
    }

    render() {
        const { query_data } = this.props;
        return (
            <div className='results-bq-cuts'>
                {this.renderCutsButtons()}
                {query_data
                    ?
                    <hr />
                    :
                    null
                }
                {this.renderAllNothingButtons()}
                {query_data
                    ?
                    <hr />
                    :
                    null
                }
            </div>
        )
    }
}

.results-modal {
    @media all and (max-width: 1250px) {
        max-width: 95%;
    }
    max-width: 1200px;

    .modal-content {

        .modal-body {
            // padding: 0;
            margin-left: 13px;
            margin-right: 13px;

            .results-bq-cuts {
                .col {
                    padding:2px;
                }

                .cuts-btn {
                    font-size: 11px;
                    padding: 3px;
                    width: 100%;
                    box-shadow: none;
                }

                .cuts-btn-active {
                    font-size: 11px;
                    padding: 3px;
                    width: 100%;
                    background-color: $croner-blue;
                    box-shadow: none;
                } 

                h5 {
                    text-align: left;                
                }

                hr {
                    margin-top: 5px;
                    margin-bottom: 5px;
                }
            }
        }
    }
}

Compiled HTML here: 此处编译的HTML:

在此处输入图片说明

Turns out it was an issue with Safari 10.0.0. 原来这是Safari 10.0.0的问题。 Upgraded the VM I have macOS running in which upgraded Safari and now the issue is gone. 升级了VM,我运行了macOS,在其中升级了Safari,现在问题不再存在了。 Saw some responses that seemed to indicate the issue was addressed in Safari 10.1. 看到一些似乎表明该问题已在Safari 10.1中解决的响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flex项目在Safari中溢出容器 - Flex items overflowing container in Safari 为什么容器div不包装子div(容器溢出了) - Why is container div not wrapping the child divs (which are overflowing the container) Angular 7 App 样式在 Safari、Opera 和 IE 中损坏,在 Chrome、Firefox、Vivaldi 和 Edge 中正常 - Angular 7 App styling broken in Safari, Opera & IE, fine in Chrome, Firefox, Vivaldi & Edge SVG 在 chrome 中溢出父容器但不是 firefox - SVG overflowing parent container in chrome but not firefox 将元素添加到非包装容器中,在左侧溢出 - Add elements to non-wrapping container, overflowing on left side tinymce-4,自定义按钮在Chrome和Firefox中正常工作但在Safari中无效 - 为什么? - tinymce-4 with custom buttons working fine in Chrome & Firefox But not working in Safari - Why? 奇怪的布局行为,css 列在 Chrome 中包裹溢出的元素 - Odd layout behaviour with css columns wrapping overflowing elements in Chrome 镀铬和野生动物园的圆形按钮断裂 - Rounded buttons breaks in chrome and safari <br> 内 <pre> 在Safari中可以使用,但在Chrome或Edge中不能使用? - <br> inside <pre> works in Safari but not Chrome or Edge? 在Safari中无法显示DIV和图像,在Chrome和Firefox中可以正常显示 - DIVs and images not showing in Safari, fine in Chrome and Firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM