0

I have a pageBlockSection that moves/jumps up the screen when a value has been entered. How can I fix this and its contained inputField in place?

If I use the following, when the field is changed the section jumps upwards around half the field height.

       <apex:pageBlockSection title="Residential Postcode" columns="1" collapsible="false">
            <apex:inputText id="myField"
                            label="myField"
                            value="{!myField}"
                            size="12" maxlength="12">
                <apex:actionSupport event="onchange" reRender="sectionOne, sectionTwo" />
            </apex:inputText>
        </apex:pageBlockSection>

If I use the following the label goes missing and the input field is left justified not

       <apex:pageBlockSection title="Residential Postcode" columns="1" collapsible="false">
            <apex:actionSupport event="onchange" reRender="sectionOne, sectionTwo" >
            <apex:inputText id="myField"
                            label="myField"
                            value="{!myField}"
                            size="12" maxlength="12" />
            </apex:actionSupport>
        </apex:pageBlockSection>
  • Your second code sample is invalid and should cause compile errors. Your first version is the right way to do it. As for the field jumping around, I've never experienced that sort of behavior. – gNerb May 24 at 16:06
  • Another note, try to use the <apex:pageBlockSectionItem> tag – gNerb May 24 at 16:09
  • The compilation error was a typo introduced while sanitising/making a minimal example. I've identified the issue and will post an answer for others momentarily. – Martin of Hessle May 28 at 10:46
0

I've solved this issue and will share it so that others experience it. The issue seems to be caused by the action support generating different markup with the pageBlock on re-rendering, moving the action support outside the apex:pageBlockSection generate the same markup each time.

        <apex:actionSupport event="onchange" reRender="existingThings">
            <apex:pageBlockSection title="Residential Postcode" columns="1" collapsible="false">
                <apex:inputText id="consumerPostcode"
                                label="Postcode"
                                value="{!consumerPostcode}"
                                size="12" maxlength="8" />
            </apex:pageBlockSection>
        </apex:actionSupport>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.